package com.example.medical.controller.user;

import com.example.medical.entity.dto.UserGetLeadershipListDto;
import com.example.medical.service.LeadershipService;
import com.example.medical.utils.common.enums.Code;
import com.example.medical.utils.common.result.Result;
import com.example.medical.utils.config.BaseContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/leadership")
public class UserLeadershipController {

    @Autowired
    private LeadershipService leadershipService;

    @PostMapping("/get_leadership_list")
    public Result UserGetLeadershipList(@RequestBody UserGetLeadershipListDto dto){
        return leadershipService.UserGetLeadershipList(dto);
    }

    @GetMapping("/get_leadership_detail")
    public Result UserGetLeadershipDetail(@RequestParam("id") Long id){
        if (BaseContext.getCurrentId()==null) {
            return Result.errorResult(Code.NEED_LOGIN);
        }
        return Result.okResult(leadershipService.getById(id));
    }

}
